﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using WHC.Hotel.BLL;
using WHC.Hotel.Entity;
using WHC.OrderWater.Commons;

namespace WHC.Hotel.UI.Report
{
    public partial class TeaCustomerReport : BaseForm
    {
        public TeaCustomerReport()
        {
            InitializeComponent();
        }

        private void FrmKFCustomer_Load(object sender, EventArgs e)
        {
            InitDictItem();

            this.winGridView1.ProgressBar = this.toolStripProgressBar1.ProgressBar;
            this.winGridView1.AppendedMenu = this.contextMenuStrip1;
        }

        private void InitDictItem()
        {
            this.txtRoomType.Items.Clear();
            List<TeaSuiteTypeInfo> list = BLLFactory<TeaSuiteType>.Instance.GetAll();
            foreach (TeaSuiteTypeInfo typeInfo in list)
            {
                CListItem item = new CListItem(typeInfo.Name, typeInfo.Name);
                this.txtRoomType.Items.Add(item);
            }
        }

        private void BindData()
        {
            #region 添加别名解析
            //[OrderNo], [RoomNo], [RoomType], [Persons], [Waiter], [CaculateType], [AtLeaseMoney], [Price], [BuyOutPrice], [CustomerName], [DepositMoney], [Note], 
            //[Createor], [CreateDate], [IsCheckOut], [CheckOutDate], [BillNumber]
            this.winGridView1.AddColumnAlias("RoomNo", "餐台号");
            this.winGridView1.AddColumnAlias("RoomType", "房间类型");
            this.winGridView1.AddColumnAlias("Persons", "人数");
            this.winGridView1.AddColumnAlias("Waiter", "服务生");
            this.winGridView1.AddColumnAlias("CaculateType", "计费方式");
            this.winGridView1.AddColumnAlias("AtLeaseMoney", "最低消费");
            this.winGridView1.AddColumnAlias("Price", "单价");
            this.winGridView1.AddColumnAlias("BuyOutPrice", "买断价格");
            this.winGridView1.AddColumnAlias("DepositMoney", "押金");
            this.winGridView1.AddColumnAlias("Creator", "下单业务员");
            this.winGridView1.AddColumnAlias("CreateDate", "下单时间");
            this.winGridView1.AddColumnAlias("Status", "当前状态");
            this.winGridView1.AddColumnAlias("CheckOutDate", "离店时间");
            this.winGridView1.AddColumnAlias("BillNumber", "结账单号");
            this.winGridView1.AddColumnAlias("Note", "备注");
            #endregion

            SearchCondition condition = new SearchCondition();
            condition.AddCondition("RoomNo", this.txtContent.Text, SqlOperator.Like)
                .AddCondition("RoomType", this.txtRoomType.Text, SqlOperator.Like);
            if (this.checkBox1.Checked)
            {
                condition.AddCondition("IsCheckOut", 1, SqlOperator.Equal);
            }

            this.winGridView1.DisplayColumns = "RoomNo,RoomType,Persons,Waiter,CaculateType,AtLeaseMoney,Price,BuyOutPrice,DepositMoney,Createor,CreateDate,Status,CheckOutDate,BillNumber,Note";
            DataTable dt = BLLFactory<TeaOrder>.Instance.GetCustomerReport(condition.BuildConditionSql(DatabaseType.SqlServer));
            this.winGridView1.DataSource = dt.DefaultView;
            this.winGridView1.PrintTitle = Portal.gc.gAppUnit + " -- " + "茶室来宾信息查询报表";
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void txtContent_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnSearch_Click(null, null);
            }
        }

        private void menu_Refresh_Click(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
